import axios from 'axios'

const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:5000'

const api = axios.create({
  baseURL: API_BASE_URL,
  headers: {
    'Content-Type': 'application/json'
  }
})

export const gameService = {
  // 创建房间
  async createRoom(roomData) {
    const response = await api.post('/api/game/rooms', roomData)
    return response.data
  },

  // 加入房间
  async joinRoom(joinData) {
    const response = await api.post('/api/game/rooms/join', joinData)
    return response.data
  },

  // 获取房间信息
  async getRoom(roomId) {
    const response = await api.get(`/api/game/rooms/${roomId}`)
    return response.data
  },

  // 发送涂色动作
  async paintAction(paintData) {
    const response = await api.post('/api/game/paint', paintData)
    return response.data
  }
}

export default gameService
